package longrise.phone.com.bjjt_jyb.compensate;

import android.content.Context;
import android.view.View;
import android.widget.Button;
import android.widget.LinearLayout;
import android.widget.TextView;
import android.widget.Toast;

import com.longrise.android.FormParameter;
import com.longrise.android.FrameworkManager;
import com.longrise.android.LFView;
import com.longrise.android.util.IntenetUtil;

import longrise.phone.com.bjjt_jyb.R;


/**
 * 进入快处快赔的安全提示，Created by Administrator on 2016/5/12.
 */
public class SafeWarningView extends LFView implements View.OnClickListener {
    private Context context = null;
    private View view = null;
    private Button bt_safewarining_ensure;
    private LinearLayout hn_btn_back;


    public SafeWarningView(Context c) {
        super(c);
        this.context = c;
    }

    @Override
    public void refreshByTime() {

    }

    @Override
    public FormParameter getFormParameter() {
        FormParameter fp = new FormParameter();
        fp.setShowtitle(false);
        return fp;
    }

    @Override
    public void refresh() {

    }

    @Override
    public View getView() {
        return view;
    }

    @Override
    public void init() {
        initView();
        regEvent(true);
    }

    private void initView() {
        view = View.inflate(context, R.layout.view_safewarning, null);
        bt_safewarining_ensure = (Button) view.findViewById(R.id.bt_safewarining_ensure);
        hn_btn_back = (LinearLayout) view.findViewById(R.id.hn_btn_back);
        TextView tv_title = (TextView) view.findViewById(R.id.tv_title);
        tv_title.setText("安全提示");
        // 判断是否有网络连接
        if (IntenetUtil.getNetworkState(context) == IntenetUtil.NETWORN_NONE) {
            Toast.makeText(context, "没有网络连接", Toast.LENGTH_SHORT).show();
            return;
        }
    }

    private void regEvent(boolean b) {
        if (null != bt_safewarining_ensure) {
            bt_safewarining_ensure.setOnClickListener(b ? this : null);
        }

        if (null != hn_btn_back) {
            hn_btn_back.setOnClickListener(b ? this : null);
        }
    }

    @Override
    public void onClick(View v) {
        switch (v.getId()) {
            case R.id.bt_safewarining_ensure:
                PromptView promptview = new PromptView(context);
                FrameworkManager.getInstance().showNewForm(context, promptview);
                break;
            case R.id.hn_btn_back:
                closeForm();
                OnDestroy();
                break;
        }
    }
}
